// index.js
// 获取应用实例
import { generateGridList } from '../list/utils'
const app = getApp()

Page({
  data: {
    //存放轮播图数据
    swiperlist:[],
    gridlist:[],
    imge:[
      {id:0,imgUrl:'/images/six/knowledge.png'},
      {id:1,imgUrl:'/images/six/enter.png'},
      {id:2,imgUrl:'/images/six/person.png'},
      {id:3,imgUrl:'/images/six/problem.png'},
      {id:4,imgUrl:'/images/six/inform.png'},
      {id:5,imgUrl:'/images/six/new.png'},
],
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    canIUseGetUserProfile: false,
    canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
  },

  onLoad() {
    wx.setNavigationBarTitle({
      title: 'ACM'
    })
    app.globalData.List=generateGridList(10,2)
    if (wx.getUserProfile) {
      this.getSwiperlist(),
      this.getGridlist(),
      this.setData({
        canIUseGetUserProfile: true
      })
    }
     // 注册分享功能
     wx.showShareMenu({
      withShareTicket: true, // 开启分享到群的选项
      success(res) {
        // 分享成功
      },
      fail(res) {
        // 分享失败
      }
    })
  },
  onShareAppMessage(res) {
    return {
      title: '分享标题',
      path: '/pages/index/index',
      imageUrl: 'https://example.com/share.jpg'
    }
  },

//获取轮播图数据
getSwiperlist(){
  wx.request({
    url: 'http://192.168.43.252:8081/api/admin/photos?current=1&size=18&albumId=24&isDelete=0',
    method:'GET',
    header: {
      'content-type': 'application/json'
  },
    success:(res)=>{
     // console.log(res)
      this.setData({
        swiperlist:res.data.data.recordList
      })
      console.log(this.data.swiperlist)
    }
  })
},


//六宫格
getGridlist(){
  wx.request({
    url: 'http://192.168.43.252:8081/api/admin/categories?current=1&size=10',
    method: 'GET',
    success: (res)=>{
      this.setData({
        gridlist: res.data.data.recordList
      })
  
    }
  })
}
})
